module FeedsHelper
  def link_to_edit_feed(feed)
    str = ""
    if feed.is_a?(Feed::InstallCreated)
      str = "#{link_to '编辑', edit_installation_order_url(feed),
      :method => :get,
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::Installed)
      str = "#{link_to '编辑', edit_installed_order_url(feed),
      :method => :get,
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::InstallUnfinished)
      str = "#{link_to '编辑', edit_install_unfinished_order_url(feed),
      :method => :get,
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::AfterServiceCreated)
      str = "#{link_to '编辑', edit_after_serviced_order_url(feed),
      :method => :get,
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::AfterServiceFinished)
      str = "#{link_to '编辑', edit_after_service_finished_order_url(feed),
      :method => :get,
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::AfterServiceUnfinished)
      str = "#{link_to '编辑', edit_after_service_unfinished_order_url(feed),
      :method => :get,
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::OrderMadeCreated)
      str = "#{link_to '编辑', edit_order_made_order_url(feed),
      :method => :get,
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::EnterCreated)
      str = "#{link_to '编辑', edit_enter_order_url(feed),
      :method => :get,
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::PaymentCreated)
      str = "#{link_to '编辑', edit_payment_order_url(feed),
      :method => :get,
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::OrderItemCompleted)
      str = "#{link_to '编辑', edit_completed_order_url(feed.order_item),
      :method => :get,
      :remote => true,
      :class => 'ud '}"
    end
    raw str
  end

  def link_to_destroy_feed(feed)
    str = ""
    if feed.is_a?(Feed::InstallCreated)
      str = "#{link_to '删除', destroy_installation_order_url(feed),
      :method => :delete,
      :confirm => "确定要删除派工项吗？",
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::Installed)
      str = "#{link_to '删除', destroy_installation_order_url(feed),
      :method => :delete,
      :confirm => "确定要删除完成项吗？",
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::InstallUnfinished)
      str = "#{link_to '删除', destroy_installation_order_url(feed),
      :method => :delete,
      :confirm => "确定要删除该安装未完成项吗？",
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::AfterServiceCreated)
      str = "#{link_to '删除', destroy_after_service_order_url(feed),
      :method => :delete,
      :confirm => "确定要删除售后服务项吗？",
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::AfterServiceFinished)
      str = "#{link_to '删除', destroy_after_service_order_url(feed),
      :method => :delete,
      :confirm => "确定要删除该售后完成项吗？",
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::AfterServiceUnfinished)
      str = "#{link_to '删除', destroy_after_service_order_url(feed),
      :method => :delete,
      :confirm => "确定要删除该售后未完成项吗？",
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::OrderMadeCreated)
      str = "#{link_to '删除', destroy_order_made_order_url(feed),
      :method => :delete,
      :confirm => "确定要删除订做项吗？",
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::EnterCreated)
      str = "#{link_to '删除', destroy_enter_order_url(feed),
      :method => :delete,
      :confirm => "确定要删除入库项吗？",
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::PaymentCreated)
      str = "#{link_to '删除', destroy_payment_order_url(feed),
      :method => :delete,
      :confirm => "确定要删除订做付款吗？",
      :remote => true,
      :class => 'ud '}"
    end
    if feed.is_a?(Feed::OrderItemCompleted)
      str = "#{link_to '删除', destroy_completed_order_url(feed),
      :method => :delete,
      :confirm => "确定要删除结束项吗？",
      :remote => true,
      :class => 'ud '}"
    end
    raw str
  end
end
